package com.hhsjdesign.dynamicui.core

import com.hhsjdesign.dynamicui.utils.ClassCachePool
import com.hhsjdesign.dynamicui.utils.DynamicUIConfig
import com.hhsjdesign.dynamicui.utils.DynamicUIConfigImplJava

class DynamicUI private constructor() {
    internal object IN {
        var INSTANCE = DynamicUI()
    }

    var initialized = false
    fun hasInit(): Boolean {
        return initialized
    }

    companion object {
        @JvmStatic
        fun inject(config: DynamicUIConfig) {
            if (!IN.INSTANCE.initialized) {
                ClassCachePool.init(config)
                IN.INSTANCE.initialized = true
            }
        }

        @JvmStatic
        fun inject() {
            check(!IN.INSTANCE.initialized) { "HHSJ DYNAMIC UI has been initialized,do not do it again!" }
            val config: DynamicUIConfig = DynamicUIConfigImplJava()
            ClassCachePool.init(config)
            IN.INSTANCE.initialized = true
        }
    }
}